/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import React, { PureComponent } from 'react';
import PageHeaderLayout from '@/layouts/PageHeaderLayout';
import StandardTab from '@/components/StandardTab';
import { connect } from 'dva';
import styles from '../style.less';
import MessageSignature from './MessageSignature';
import RegionalAgent from './RegionalAgent';
import PushSet from './PushSet';
import NotificationManagement from './NotificationManagement';
import MixInStorage from './MixInStorage';
import SiteScanManage from './SiteScanManage';

@connect(({ router, user }) => ({ router, currentUser: user.currentUser }))
export default class Home extends PureComponent {
  state = {
    activeKey: 'regionalAgent',
  };

  onChange = activeKey => {
    this.setState({
      activeKey,
    });
  };

  render() {
    const { currentUser } = this.props;
    const { activeKey } = this.state;
    const { quickLoginType, is_sitescan } = currentUser || {};
    const panes = [
      {
        tab: '现有代理区域',
        key: 'regionalAgent',
        component: <RegionalAgent />,
      },
      {
        tab: '短信签名设置',
        key: 'messageSignature',
        component: <MessageSignature />,
      },
      {
        tab: '报表数据推送设置',
        key: 'pushSet',
        component: <PushSet />,
      },
      {
        tab: '通知管理',
        key: 'NotificationManagement',
        component: <NotificationManagement />,
      },
    ];

    if (quickLoginType) {
      panes.push({
        tab: '代入库',
        key: 'MixInStorage',
        component: <MixInStorage />,
      });
    }

    if (is_sitescan == 1) {
      panes.push({
        tab: '场地扫描管理',
        key: 'ScanCode',
        component: <SiteScanManage />,
      });
    }

    return (
      <PageHeaderLayout title="管理和设置">
        <div className={styles.main}>
          <StandardTab name="setup" panes={panes} activeKey={activeKey} onChange={this.onChange} />
        </div>
      </PageHeaderLayout>
    );
  }
}
